public class P40Volatile {
  public static volatile boolean stop = false;
  // public static boolean stop = false;

  public static void main(String[] args) {
    new Thread(new Runnable() {
      @Override
      public void run() {
        while (!stop) {

        }
      }
    }).start();
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    stop = true;
  }
}
